/**
 * @AccessMessage.java  COPYRIGHT xj
 * 
 * Created on 2017年7月5日 下午2:14:55
 */
package xj.toolkit.access.msg;

import java.util.UUID;

import xj.toolkit.bean.CommonsHeader;
import xj.toolkit.util.DefaultPropertiesSupport;
import xj.toolkit.util.MutableIdentifyable;
import xj.toolkit.access.AccessHeader;

/**
 * Access 消息。
 * 
 * @author <a href="mailto:cxj2000@gmail.com">xj.cao</a>
 *
 */
public class AccessMessage extends DefaultPropertiesSupport implements MutableIdentifyable {

	/**
	 * 包含UUID。
	 */
	private CommonsHeader commonHeader = null;

	private AccessHeader accessHeader = null;

	@Override
	public UUID getIdentification() {
		if (commonHeader == null) {
			return null;
		}
		return new UUID(commonHeader.getFirstTransaction(), commonHeader.getSecondTransaction());
	}

	@Override
	public void setIdentification(UUID id) {
		if (id == null) {
			return;
		}

		if (commonHeader == null) {
			return;
		}

		commonHeader.setFirstTransaction(id.getLeastSignificantBits());
		commonHeader.setSecondTransaction(id.getMostSignificantBits());
	}

	public CommonsHeader getCommonHeader() {
		return commonHeader;
	}

	public void setCommonHeader(CommonsHeader commonHeader) {
		this.commonHeader = commonHeader;
	}

	public AccessHeader getAccessHeader() {
		return accessHeader;
	}

	public void setAccessHeader(AccessHeader accessHeader) {
		this.accessHeader = accessHeader;
	}

}
